<?php

// Error reporting:
error_reporting(E_ALL^E_NOTICE);

// Including the DB connection file:
require 'common/connectDB.php';

$extension='';
$files_array = array();


/* Opening the thumbnail directory and looping through all the thumbs: */

$dir_handle = @opendir($directory) or die("There is an error with your file directory!");

while ($file = readdir($dir_handle))  {
	/* Skipping the system files: */
	if($file{0}=='.') continue;
	
	/* end() returns the last element of the array generated by the explode() function: */
	$extension = strtolower(end(explode('.',$file)));
	
	/* Skipping the php files: */
	if($extension == 'php') continue;

	$files_array[]=$file;
}
/* Sorting the files alphabetically */
sort($files_array,SORT_STRING);

$file_downloads=array();

$result = mysql_query("SELECT * FROM download_manager");

if(mysql_num_rows($result))
while($row=mysql_fetch_assoc($result))
{
	/* 	The key of the $file_downloads array will be the name of the file,
		and will contain the number of downloads: */
		
	$file_downloads[$row['filename']]=$row['downloads'];
}
?>

<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
<link rel="shortcut icon" href="/content/themes/default/images/icons/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
<title>GameCohet::Wap tải game cho điện thoại</title>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
</head><body>

<div class="head"><img src="./img/ico/logo.png" alt="dizond.ru" /></div>

<div class="title2">
	<span class="m_t2">
		<a href="gameImg.php">LINK 1 | </a>
		<a href="#">LINK 2 | </a>
		<a href="#">LINK 3</a>
	</span>
</div>

<!-- >>>>>>>>>>>>>>>>>>>>>>>>> GAME ONLINE >>>>>>>>>>>>>>>>>>>>>>>>> -->
<?php
	$randId = rand(1, $countGameOnline);
	$notTypical = array();
	while($row = mysql_fetch_array($listGameOnline)) {
		if($row['game_id'] == $randId) {
			$typicalOnline = $row;
?>
			<div class="title"><span class="m_t">GAME ONLINE (<?php echo $countGameOnline; ?>)</span></div>
			<div class="news">
				<span class="m_news">
					<a href="#">
						<h3><?php echo $typicalOnline['game_name'];?> | <?php echo $typicalOnline['game_intro'];?></h3>
						<img src="<?php echo $typicalOnline['game_img'];?>" width="50" height="50" />
					</a>
				</span>
				<div class="description">
					<?php echo $typicalOnline['game_description'];?>
				</div>
			</div>
<?php
		} else {
			array_push($notTypical, $row);
		}
	}
	foreach ($notTypical as $listGame) {
		if($listGame['game_id']%2 == 1) {
	?>
			<div class="menu">
				<img src="<?php echo $listGame['game_img'];?>" alt="ico" width="20" height="20"/>
				<a href="./ork.html"><?php echo $listGame['game_name'];?></a> |
				<font color="#006666"><?php echo $listGame['game_intro'];?></font> |
				<font color="#CC6600">
					Tải về: 
					<a href="<?php echo $listGame['game_jar'];?>">jar ::</a>
					<a href="<?php echo $listGame['game_jad'];?>">jad :: </a>
					<a href="<?php echo $listGame['game_android'];?>">android</a>
				</font>
			</div>
		<?php 
		}
		if($listGame['game_id']%2 == 0) {
		?>
			<div class="menu2">
				<img src="<?php echo $listGame['game_img'];?>" alt="ico" width="20" height="20"/>
				<a href="./ork.html"><?php echo $listGame['game_name'];?></a> |
				<font color="#006666"><?php echo $listGame['game_intro'];?></font> |
				<font color="#CC6600">
					Tải về: 
					<a href="<?php echo $listGame['game_jar'];?>">jar ::</a>
					<a href="<?php echo $listGame['game_jad'];?>">jad :: </a>
					<a href="<?php echo $listGame['game_android'];?>">android</a>
				</font>
			</div>
<?php 
		}
	}
?>

<!-- >>>>>>>>>>>>>>>>>>>>>>>>> GAME OFFLINE >>>>>>>>>>>>>>>>>>>>>>>>> -->
<?php
	$randId = rand(1, $countGameOffline);
	$notTypical = array();
	while($row = mysql_fetch_array($listGameOffline)) {
		if($row['game_id'] == $randId) {
			$typicalOffline = $row;
?>
			<div class="title"><span class="m_t">GAME OFFLINE (<?php echo $countGameOffline; ?>)</span></div>
			<div class="news">
				<span class="m_news">
					<a href="#">
						<h3><?php echo $typicalOffline['game_name'];?> | <?php echo $typicalOffline['game_intro'];?></h3>
						<img src="<?php echo $typicalOffline['game_img'];?>" width="50" height="50" />
					</a>
				</span>
				<div class="description">
					<?php echo $typicalOffline['game_description'];?>
				</div>
			</div>
<?php
		} else {
			array_push($notTypical, $row);
		}
	}
	foreach ($notTypical as $listGame) {
		if($listGame['game_id']%2 == 1) {
	?>
			<div class="menu">
				<img src="<?php echo $listGame['game_img'];?>" alt="ico" width="20" height="20"/>
				<a href="./ork.html"><?php echo $listGame['game_name'];?></a> |
				<font color="#006666"><?php echo $listGame['game_intro'];?></font> |
				<font color="#CC6600">
					Tải về: 
					<a href="<?php echo $listGame['game_jar'];?>">jar ::</a>
					<a href="<?php echo $listGame['game_jad'];?>">jad :: </a>
					<a href="<?php echo $listGame['game_android'];?>">android</a>
				</font>
			</div>
		<?php 
		}
		if($listGame['game_id']%2 == 0) {
		?>
			<div class="menu2">
				<img src="<?php echo $listGame['game_img'];?>" alt="ico" width="20" height="20"/>
				<a href="./ork.html"><?php echo $listGame['game_name'];?></a> |
				<font color="#006666"><?php echo $listGame['game_intro'];?></font> |
				<font color="#CC6600">
					Tải về: 
					<a href="<?php echo $listGame['game_jar'];?>">jar ::</a>
					<a href="<?php echo $listGame['game_jad'];?>">jad :: </a>
					<a href="<?php echo $listGame['game_android'];?>">android</a>
				</font>
			</div>
<?php 
		}
	}
?>

<div class="cont">
 &bull; <a href="./chat.html"></a><br />
 &bull; <a href="./chat.html">История Изантии</a><br />
 &bull; <a href="./chat.html">Гнездовье Гарпий</a><br />
 &bull; <a href="./chat.html">Подземелье Блимпов</a><br />
 &bull; <a href="./chat.html">Пещеры Орков</a></div>

<div class="copy">&copy; <a href="#">THÀNH PHẠM</a></div>

<div class="foot"><img src="./img/ico/ch.png" alt="ico" /></div>
</body></html>